package edu.wpi.first.wpilibj.templates;

import edu.wpi.first.wpilibj.Relay;

/**
 *
 * @author Robotics
 */
public class FireThread extends Thread {

    private static final long FIRE_DELAY = 375; // fire delay in ms
    // on b/c we specify the direction on instantiation of the Relay
    private static final Relay.Value BALL_CON_DIRECTION = Relay.Value.kOn;
    private Relay solFire, solRetract, ballController;

    public FireThread() {
        super();
    }

    public FireThread(Relay solF, Relay solR, Relay ballCon) {
        super();
        solFire = solF;
        solRetract = solR;
        ballController = ballCon;
    }

    public void run() {
        try {
            // stop ball control
            ballController.set(Relay.Value.kOff);
            // fire
            solFire.set(Relay.Value.kForward);
            solRetract.set(Relay.Value.kOff);
            // wait
            sleep(FIRE_DELAY);
            // retract
            solFire.set(Relay.Value.kOff);
            solRetract.set(Relay.Value.kForward);
            // start ball control
            ballController.set(BALL_CON_DIRECTION);
        } catch (InterruptedException ex) {
//			ex.printStackTrace();
        }
    }
}
